#include "CCharGeneralInfoPacket.h"
#include "CChar.h"

CCharGeneralInfoPacket::CCharGeneralInfoPacket(CChar * schar) {
	this->type = 0xE2;
	this->size = 0x16;

	memset(this->data, 0, sizeof(data));

	memcpy(&this->data[0x04-4], &(schar->m_id), 4);

	memcpy(&this->data[0x18-4], &(schar->m_targId), 2);

	int hp = schar->getHp();
	int mp = schar->getMp();
	memcpy(&this->data[0x08-4], (char *)&hp, 4);
	memcpy(&this->data[0x0C-4], (char *)&mp, 4);

	this->data[0x1D-0x04] = (unsigned char)(((float)schar->h.hp / (float)(schar->getMaxHp())) * 100);
	this->data[0x1E-0x04] = (unsigned char)(((float)schar->h.mp / (float)(schar->getMaxMp())) * 100);

	this->data[0x1F-0x04] = (char)schar->getZone(); 

	memcpy(this->data+0x20,schar->m_name,strlen(schar->m_name));


}

CCharGeneralInfoPacket::~CCharGeneralInfoPacket() {

}